package com.springboot.prac.prac04_thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * 创建线程
 */
public class CreateThread {

    public static void main(String[] args) {
        CreateThread createThread = new CreateThread();
        createThread.run();
    }


    public void run() {
        new Thread(new MyThread01()).start();
        new Thread(new MyThread02()).start();
        new Thread(new FutureTask(new MyThread03())).start();
    }

    class MyThread01 extends Thread {
        @Override
        public void run() {
            System.out.println("线程1执行、、、");
        }
    }

    class MyThread02 implements Runnable {
        @Override
        public void run() {
            System.out.println("线程2执行、、、");
        }
    }

    class MyThread03 implements Callable {
        @Override
        public Object call() throws Exception {
            System.out.println("线程3执行、、、");
            return "返回结果";
        }
    }
}
